{% extends 'df_user/headButton.html' %}
{% load user_info %}
{% block content %}
    <div class="right_content clearfix">
        <h3 class="common_title2">全部订单</h3>
        {% for foo in OrderDetailList %}
            <ul class="order_list_th w978 clearfix">
                <li class="col01">{{ foo.order.date }}</li>
                <li class="col02 orderNum">订单号：{{ foo.order.id }}</li>
                <li class="col02 stress">{% verifyPay foo.order.isPy %}</li>
            </ul>

            <table class="order_list_table w980">
                <tbody>
                <tr>
                    <td width="55%">
                        {% for orderDetail in foo.orderDetail %}
                            <ul class="order_goods_list clearfix">
                                <li class="col01"><img src="/{{ orderDetail.goods.cover }}"></li>
                                <li class="col02">{{ orderDetail.goods.title }}<em>{{ orderDetail.goods.unit }}</em>
                                </li>
                                <li class="col03">{{ orderDetail.count }}</li>
                                <li class="col04">{{ orderDetail.subtotal }}元</li>
                            </ul>
                        {% endfor %}
                    </td>
                    <td width="15%">{{ foo.order.total }}元</td>
                    <td class="notPy" width="15%"></td>
                    <td width="15%"><a href="" class="oper_btn"></a></td>
                </tr>

                </tbody>
            </table>

        {% endfor %}



        <div class="pagenation">
            <a href="#">
                上一页
            </a>
            <a href="#" class="active">1</a>
            <a href="#">2</a>
            <a href="#">3</a>
            <a href="#">4</a>
            <a href="#">5</a>
            <a href="#">下一页></a>
        </div>
    </div>
{% endblock content %}

{% block script %}

    <script>
        $('.stress').each(function () {
            var res=$(this).text();
            var pay=$(this).parent().next().find('.oper_btn');
            if (res=="未支付"){
                var payNum=$(this).prev().text();
                pay.text('去付款');
                console.log(payNum[4]);
                pay.attr('href','/order/payment-'+payNum.substring(4,6));
                $(this).parent().next().find('.notPy').text('待付款');
            }else{
                pay.text('查看物流');
                $(this).parent().next().find('.notPy').text('已付款');
            }
        })
    </script>
{% endblock script %}